package com.shadow.ai.service;

import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.service.AiServices;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AiCodeServiceConfig {

    @Resource
    private ChatModel chatModel;

    /**
     * AiServices.create(AiCodeService.class, chatModel);
     * ChatMemoryStore
     * */
    @Bean
    public AiCodeService getAiCodeService() {
        MessageWindowChatMemory chatMemory = MessageWindowChatMemory.withMaxMessages(5);
        return AiServices.builder(AiCodeService.class)
                .chatModel(chatModel)
                .chatMemory(chatMemory)
                .build();
    }
}
